Hệ thống quản lý hàng tồn kho trong php

1 <?php
2
3 include(
'config.php');
4
5 if
(isset($_POST['submit']))
6 {
7 $id=$_POST[
'id'];
8 $name=mysqli_real_escape_string($db, $_POST[
'product_name']);
9 $price=mysqli_real_escape_string($db, $_POST[
'price']);
10 $quant=mysqli_real_escape_string($db, $_POST[
'quantity']);
11
12 mysqli_query($db,
"UPDATE product SET product_name='$name', price='$price' ,quantity='$quant' WHERE product_id='$id'");
13
14 header(
"Location:table.php");
15 }

16
17
18 if
(isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
19 {
20
21 $id = $_GET[
'id'];
22 $result = mysqli_query($db,
"SELECT * FROM product WHERE product_id=".$_GET['id']);
23
24 $row = mysqli_fetch_array($result);

25
26 if
($row)
27 {
28
29 $id = $row[
'product_id'];
30 $name = $row[
'product_name'];
31 $price = $row[
'price'];
32 $quant=$row[
'quantity'];
33 }

34 else

35 {
36 echo
"No results!";
37 }
38 }
39 ?>
40
41
42 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
43 <html>
44 <head>
45 <title>Edit Item</title>
46 </head>
47 <body>
48
49
50
51 <form action=
"" method="post" action="edit.php">
52 <input type=
"hidden" name="id" value="<?php echo $id; ?>"/>
53
54 <table border=
"1">
55 <tr>
56 <td colspan=
"2"><b><font color='Red'>Edit Records </font></b></td>
57 </tr>
58 <tr>
59 <td width=
"179"><b><font >Item Name<em>*</em></font></b></td>
60 <td><label>
61 <input type=
"text" name="product_name" value="<?php echo $name; ?>" />
62 </label></td>
63 </tr>
64
65 <tr>
66 <td width=
"179"><b><font color='#663300'>Price<em>*</em></font></b></td>
67 <td><label>
68 <input type=
"text" name="price" value="<?php echo $price ?>" />
69 </label></td>
70 </tr>
71
72 <tr>
73 <td width=
"179"><b><font color='#663300'>Quantity<em>*</em></font></b></td>
74 <td><label>
75 <input type=
"text" name="quantity" value="<?php echo $quant;?>" />
76 </label></td>
77 </tr>
78
79 <tr align=
"Right">
80 <td colspan=
"2"><label>
81 <input type=
"submit" name="submit" value="Edit Records">
82 </label></td>
83 </tr>
84 </table>
85 </form>
86 </body>
87 </html>


Gõ tìm kiếm nhanh...